package com.guoguo.cloudmusic.ui.login

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.guoguo.cloudmusic.logic.Repository
import com.guoguo.cloudmusic.logic.model.UserInfo
import com.guoguo.cloudmusic.ui.login.LoginUser

class LoginViewModel : ViewModel() {

    private val loginData = MutableLiveData<LoginUser>()
    val userInfo = HashSet<UserInfo.Account>()

    val userInfoLiveData = Transformations.switchMap(loginData) {
        Repository.login(it)
    }

    fun login(data: LoginUser) {
        loginData.value = data
    }
}